﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"  />
<title></title>
{php echo register_jssdk();}
<style>
#canvassudo {
	border: 1px solid black;
	width: 400px;
	height: 400px;
}
</style>
</head>
<body>
<canvas id="canvassudo" width="300" height="300"></canvas>      
<input style="display:none;" type="checkbox" id='chkUseBuffer' checked="checked" onclick='btnUseBuffer_Click()'>
</input>
<select id="seleLevel" style="display:none;">
      <option value="2" {if $temp_list['degree']==0} selected {/if}>容易</option>
      <option value="3" {if $temp_list['degree']==1} selected {/if}>一般</option>
      <option value="4" {if $temp_list['degree']==2} selected {/if}>较难</option>
      <option value="5" {if $temp_list['degree']==3} selected {/if}>困难</option>
</select>
<button id="btnInitSudo" onclick="btnInitSudo_Click()">生成新数独</button>
<button id="btnClearAll" onclick="btnClearAll_Click()">全部清除</button></td>

<script src="{MODULE_URL}template/mobile/sudo.js"></script> 
<script>
    function btnInitSudo_Click() {
        if (confirm("真得要开一新局？")) {
            var seleLevel = document.getElementById("seleLevel");
            sudo.Init(seleLevel.value);
            sudo.Draw();
        }
    }

    function btnShowOptNumber_Click() {
        var showopt = sudo.ToggleShowOptionNumber();

        var btn = document.getElementById("btnShowOptNumber");
        if (showopt)
            btn.innerText = "隐藏提示";
        else
            btn.innerText = "显示提示";

        sudo.Draw();
    }

    function btnEditMode_Click() {
        var editmode = sudo.ToggleEditMode();
        var btn = document.getElementById("btnEditMode");
        if (editmode)
            btn.innerText = "结束编辑";
        else
            btn.innerText = "编辑模式";
        sudo.Draw();

    }

    function btnClearAll_Click() {
        if (confirm("真得要清除所有的自填数字？")) {
            sudo.ClearAll();
            sudo.Draw();
        }
    }

    
    function btnUseBuffer_Click()
    {
        var ipt = document.getElementById("chkUseBuffer");
        sudo.setUseBuffer(ipt.checked);
    }
  

    var spPos = document.getElementById("spPos");
    var cavanssudo = document.getElementById("canvassudo");
    var ctx = cavanssudo.getContext("2d");
    
    var sudowidth = document.body.clientWidth;    
    var sudoheight = document.body.clientWidth;
    
    cavanssudo.style.width = sudowidth + "px";
    cavanssudo.style.height = sudoheight + "px";
	
    cavanssudo.width = sudowidth *  window.devicePixelRatio;
    cavanssudo.height = sudoheight * window.devicePixelRatio;
    
    var sudo = new Sudo(cavanssudo.width, cavanssudo.height, cavanssudo);
    
    var seleLevel = document.getElementById("seleLevel");
    sudo.Init(seleLevel.value);
    btnUseBuffer_Click();
    sudo.Draw();
		wx.ready(function () {

		    sharedata = {

		        title: "{$temp_list['share_title']}",

		        desc: "{$temp_list['share_content']}",

		        imgUrl: "{$temp_list['share_icon']}",

		        success:function(){}

		    };

		    wx.onMenuShareAppMessage(sharedata);

		    wx.onMenuShareTimeline(sharedata);

		});	
    </script>
    
</body>
</html>